package com.nl.controller.web.controller;

import com.nl.controller.common.model.OperatorLog;
import com.nl.controller.common.model.Response;
import com.nl.controller.common.util.ResponseUtil;
import com.nl.controller.web.service.TestService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SwaggerController {

     /*
     *  http://localhost:8080/swagger-ui.html
     */

    @Autowired
    private TestService test;

    @ApiOperation(value = "插入日志", notes = "测试数据插入")
    @GetMapping("test")
    public void test(){
        test.test();
    }

    @ApiOperation(value = "查询日志", notes = "分页查询数据")
    @ApiImplicitParam(name = "page", value = "第几页", required = true, dataType = "String")
    @PostMapping("/see/{page}")
    public Response queryLog(@PathVariable("page") int page){

        List<OperatorLog> list = test.queryLog(page,10);
        return ResponseUtil.sucess(list);
    }
}
